package model;

import java.util.ArrayList;

/**
 * 
 * @author Mads Nielsen
 */
public class SaleCollection {

	private static SaleCollection instance;
	private ArrayList<Sale> sales;

	private SaleCollection() {
		sales = new ArrayList<Sale>();
	}

	/**
	 * Returns singleton class instance
	 * 
	 * @return class instance
	 */
	public static SaleCollection getInstance() {
		if (instance == null) {
			instance = new SaleCollection();
		}

		return instance;
	}

	public void addSale(Sale sale) {
		sales.add(sale);
	}

	/**
	 * Returns all sales stored in record
	 * 
	 * @return array of Sale objects
	 */
	public Sale[] getAllSales() {
		return sales.toArray(new Sale[sales.size()]);
	}

}
